<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>

    <style>
      html,
      body {
        width: 100%;
        height: 100%;
        display: flex;
        background-color: #000;
        margin: 0;
      }

      .container {
        width: 40%;
        height: 500px;
        margin: auto;
        box-sizing: border-box;
        display: flex;
        justify-content: space-around;
        align-items: center;
      }

      span {
        display: block;
        min-width: 5px;
        min-height: 5px;
        background-color: #fff;
        border-radius: 50%;
        color: #fff;
        font-size: 36px;
        font-weight: bold;
      }
      span:last-child {
        background: none;
      }
    </style>
  </head>

  <body>
    <div class="container">
      <span></span><span></span><span></span><span></span><span></span
      ><span></span><span></span><span></span><span></span><span></span
      ><span></span><span></span><span></span><span></span><span></span
      ><span></span><span></span><span></span><span></span><span>&gt;</span>
    </div>

    <script>
      const list = document.querySelectorAll("span");
      const container = document.querySelector(".container");

      function getSin(min, max, i) {
        // 单个单位数值
        const item = (max - min) / list.length;
        const scale = container.clientWidth / (max - min); // 放大比例
        return Math.sin(i * item + min) * scale;
      }

      function changePos(min, max) {
        for (let i = 0; i < list.length; i++) {
          const item = list[i];
          const y = getSin(min, max, i);
          item.style.transform = `translateY(${y}px)`;
        }
      }

      // 截取函数图的 到2Π这段
      changePos(0, 2 * Math.PI);
      let speed = 0;
      // 动画
      setInterval(() => {
        speed += 0.1;
        changePos(speed, speed + 2 * Math.PI);
      }, 25);
    </script>
  </body>
</html>
